package com.xiaoyu.client.ui.activity.help;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.xiaoyu.client.R;
import com.xiaoyu.client.network.NetworkManager;
import com.xiaoyu.commonlib.network.CommonHttpResponser;
import com.xiaoyu.commonlib.ui.base.BaseActivity;
import com.xiaoyu.commonlib.ui.base.BaseActivityWithTitle;
import com.xiaoyu.commonlib.utils.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SeekProblemAppendActivity extends BaseActivityWithTitle {

    @BindView(R.id.activity_feed_back_edit)
    EditText mEdit;

    private String seekId;

    @Override
    protected void loadContentView(ViewGroup parent) {
        setTitleText("追加提问");
        LayoutInflater.from(this).inflate(R.layout.activity_feed_back,parent,true);
        ButterKnife.bind(this);
        seekId = getIntent().getStringExtra(HelpDetailActivity.SEEK_ID);
    }

    //确认按钮点击事件
    @OnClick(R.id.activity_feed_back_affirm)
    public void affirmClick(){
        if(TextUtils.isEmpty(mEdit.getText().toString())){
            ToastUtil.showToast(this,"请输入问题描述");
        }else{
            sendQuestion();
        }
    }

    private void sendQuestion(){
        NetworkManager.appendSeekQuestion(seekId, mEdit.getText().toString(), new CommonHttpResponser() {
            @Override
            public void onSuccess(String result) {
                onBackPressed();
            }

            @Override
            public void onFailed(String errorCode, String errorDiscription) {
            }
        });
    }
}
